package com.bestcem.xm.member.dao.mapper;

import com.bestcem.xm.member.entity.mysql.SyncRuleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 同步规则数据访问操作
 *
 * @author qiongyu.cui <qiongyu.cui@idiaoyan.com>
 * @date 2021/9/23 11:05
 */
@Mapper
public interface SyncRuleMapper {

    /**
     * 根据 组织id和联系人类型更新type
     *
     * @param syncRuleEntity 同步规则信息
     */
    void updateTypeByOrgIdAndMemberType(SyncRuleEntity syncRuleEntity);

    /**
     * 根据相关字段查询同步规则信息
     *
     * @param syncRuleEntity 同步规则信息
     * @return com.bestcem.xm.member.entity.mysql.SyncRuleEntity
     * @author cuiqiongyu <qiongyu.cui@idiaoyan.cn>
     * @date 2021/10/11 10:34
     */
    List<SyncRuleEntity> selectBySyncRule(SyncRuleEntity syncRuleEntity);

    /**
     * 根据syncruleId更新同步规则信息
     *
     * @param syncRuleEntity 同步规则信息
     * @return int 更新的结果条数
     * @author cuiqiongyu <qiongyu.cui@idiaoyan.cn>
     * @date 2021/10/11 10:36
     */
    int updateBySyncruleId(SyncRuleEntity syncRuleEntity);

    /**
     * 创建同步规则
     *
     * @param syncRuleEntity 同步规则信息
     * @return int 新增的条数
     * @author cuiqiongyu <qiongyu.cui@idiaoyan.cn>
     * @date 2021/10/11 10:37
     */
    int insert(SyncRuleEntity syncRuleEntity);

    /**
     * 批量创建同步规则
     *
     * @param syncRuleEntities 同步规则信息集合
     */
    int batchCreate(List<SyncRuleEntity> syncRuleEntities);

    /**
     *
     * @param orgIds
     * @param memberType
     * @param syncType
     * @return
     */
    List<SyncRuleEntity> findByOrgIdsAndMemberTypeAndWechatSyncEnabled(@Param("list") List<String> orgIds,
                                                                       @Param("memberType") int memberType,
                                                                       @Param("syncType") int syncType);
}
